package com.example.demo.AliPay.Controller;

import com.example.demo.AliPay.Service.AliPayService;
import com.example.demo.AliPay.Service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Auther: csp1999
 * @Date: 2020/11/13/21:47
 * @Description: 支付宝沙箱测试 controller
 */
@RestController
public class RefundController {

    @Autowired
    private AliPayService aliPayService;

    @Autowired
    private OrderService orderService;

    @PostMapping(value = "/refund")
    public Boolean alipay(String out_trade_nos, String total_amount,Integer id){ //订单号 退款金额
        try{
            aliPayService.refund(out_trade_nos,total_amount);
            orderService.updateOrdersStatus(id);
            return true;
        }catch (Exception e){
            return false;
        }
    }
}